//
//  BJZhuanTiJiaoYuViewController.m
//  DangXiao
//
//  Created by APPLE on 16/12/6.
//  Copyright © 2016年 APPLE. All rights reserved.
//

#import "BJZhuanTiJiaoYuViewController.h"
#import "BJShiZhengYaoWenTableViewCell.h"
#import "BJHeaderView.h"

@interface BJZhuanTiJiaoYuViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *myTableView;


@end

@implementation BJZhuanTiJiaoYuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    if (_shiZheng == YES) {
        self.navigationItem.title = @"时政要闻";
    }else{
        self.navigationItem.title = @"专题教育";
    }
}

//让分区头跟随tableView的滑动消失
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == self.myTableView)
    {
        CGFloat sectionHeaderHeight = BILIHEIGHT(39); //区头高度
        if (scrollView.contentOffset.y <= sectionHeaderHeight&&scrollView.contentOffset.y >=0) {
            scrollView.contentInset = UIEdgeInsetsMake(- scrollView.contentOffset.y, 0, 0, 0);
        } else if (scrollView.contentOffset.y >= sectionHeaderHeight) {
            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
        }
    }
}

- (void)viewDidAppear:(BOOL)animated
{
    self.navigationController.navigationBar.translucent = NO;
}

#pragma mark ---- 设置TbaleView
- (void)initUI{
    
    //    [self setHeaderUI];
    
    BJHeaderView *VIEW = [[BJHeaderView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, BILIHEIGHT(280))];
    
    
    _myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight - 64) style:(UITableViewStylePlain)];
    _myTableView.delegate = self;
    _myTableView.dataSource = self;
    _myTableView.backgroundColor = GrayLabel;
    _myTableView.tableHeaderView = VIEW;
    //    _myTableView.tableHeaderView = cellView;
    //    注册cell
    [_myTableView registerClass:[BJShiZhengYaoWenTableViewCell class] forCellReuseIdentifier:@"BJShiZhengYaoWenTableViewCell"];
   
    
    [self.view addSubview:_myTableView];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 16;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BJShiZhengYaoWenTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BJShiZhengYaoWenTableViewCell" forIndexPath:indexPath];
  
    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return BILIHEIGHT(90);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
